let zTree, rMenu;


function ajaxDataFilter(treeId, parentNode, responseData) {
    let datas = []
    for (let i = 0; i < responseData.data.length; i++) {
        datas[i] = responseData.data[i]
        datas[i].downloadUrl = responseData.data[i].url;
        datas[i].url = null
        datas[i].drap = true
    }
    return datas;
}

function initZTree() {
    let setting = {
        edit: {
            enable: true,
            showRemoveBtn: false
        },
        async: {
            enable: true,
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            url: "/gofile/filelist",
            autoParam: ["id=path"],
            otherParam: ["req", Math.random() + ""],
            dataFilter: ajaxDataFilter
        },
        data: {}, callback: {
            onClick: ztreeCallback.onClick,
            onRightClick: ztreeCallback.onRightClick,
            onDrop: ztreeCallback.onDrop,
            beforeDrop: ztreeCallback.beforeDrop
        }
    };

    zTree = $.fn.zTree.init($("#treeDemo"), setting);
}


$(function () {
    rMenu = $("#rMenu");
    //loadData("")
    initZTree()
});
